<!--
 * @LastEditors: 七七
 * @Date: 2023-01-11 09:28:37
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>数组字面量</title>
</head>

<body>
  <script>
    // 字面量创建数组
    var arr = [];

    // 创建并指定数组的元素
    var arr = [1, 2, 3, 5, 6];
    console.log(arr); //[1,2,3,5,6]

    // 数组中的元素可以是任何的数据类型
    var obj = { name: 'lucy' };
    arr[arr.length] = obj;
    console.log(arr); //[1,2,3,5,6,{name:'lucy'}]
    arr[arr.length] = ['hello', true, false, null, undefined];
    console.log(arr); //[1,2,3,5,6,{name:'lucy'},['hello', true, false, null, undefined]]

  </script>
</body>

</html>